<?php
if(empty($_GET['is_p'])) define('M_NOUSER',1);
include_once dirname(dirname(__FILE__)).'/include/general.inc.php';
if_siteclosed(1);
include_once M_ROOT.'./include/common.fun.php';
m_clear_ob();
if(empty($tname)) mexit();
$refarr = @parse_url($_SERVER['HTTP_REFERER']);
if(!$jsrefsource || empty($refarr['host']) || in_array($refarr['host'],explode("\r\n",$jsrefsource))){
	if(($tag = read_tag('ctag',$tname)) && (@$tag['js'] || @$tag['pmid'])){
		parse_str(un_virtual($_SERVER['QUERY_STRING']),$temparr);
		unset($temparr['t']);
		$_clspc = new cls_pagecache();
		$_clspc->read($temparr,array('is_p' => empty($is_p) ? 0 : 1),9);
		unset($temparr);
		
		$_da = empty($data) ? array() : $data;
		js_refresh($tname,$tag);
		@extract($btags);
		@extract($_da);
		_aenter($_da,1);
		ob_clean();
		@include M_ROOT."template/$templatedir/pcache/js".(empty($is_p) ? '' : '_p')."_$tname.php";
		$_content = ob_get_contents();
		ob_clean();
		if($_clspc->needsave) $_clspc->save($_content);
		js_write($_content);
	}
}else js_write('NoPermission');
mexit();
function tpl_permission($pmid=0){
	global $curuser;
	return $curuser->pmbypmids('tpl',$pmid);
}
?>
